package com.example.mobile2021606185zhn0408;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle1;
    private TextView tvMain12;
    private TextView tvMain13;
    private TextView intone;
    private EditText edtOne;
    private TextView inttwo;
    private EditText edtTwo;
    private Button btn1;
    private TextView TVResult1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String string = edtOne.getText().toString();
                String string2 = edtTwo.getText().toString();
                int num1=Integer.valueOf(string).intValue();
                int num2=Integer.valueOf(string2).intValue();
                num1=num1+num2;
                string=String.valueOf(num1);
                TVResult1.setText(string);
            }
        });
    }

    private void initView() {
        tvMainTitle1 = (TextView) findViewById(R.id.tv_main_title1);
        tvMain12 = (TextView) findViewById(R.id.tv_main_1_2);
        tvMain13 = (TextView) findViewById(R.id.tv_main_1_3);
        intone = (TextView) findViewById(R.id.intone);
        edtOne = (EditText) findViewById(R.id.edt_one);
        inttwo = (TextView) findViewById(R.id.inttwo);
        edtTwo = (EditText) findViewById(R.id.edt_two);
        btn1 = (Button) findViewById(R.id.btn_1);
        TVResult1 = (TextView) findViewById(R.id.TV_result_1);
    }
}